
(function () {
    $.fn.extend({
        omouse() {

            //回到顶部
            class toTop {
                constructor(el) {
                    this.el = el;
                    this.srcTop = 0;
                    this.mouseEvent();

                }
                mouseEvent() {
                    $(document).scroll(function () {
                        this.srcTop = $(document).scrollTop();
                    })
                    this.el.click(() => {
                        console.log(111);
                        $("body,html").stop().animate({
                            //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置。
                            scrollTop: 0
                        }, 1000)
                    })
                }


            }
            //五星好评
            class goodstar {
                constructor(el) {
                    this.el = el;
                    this.shixin = "★";
                    this.kongxin = "☆";
                    this.mouseEvent9()
                }
                mouseEvent9() {
                    let that = this;
                    this.el.find(".comment li").on("mouseenter", function (e) {
                        $(e.target).text(that.shixin).prevAll().text(that.shixin).end().next().text(that.kongxin)
                    }).on("click", function () {
                        $(this).addClass("abc").siblings().removeClass("abc")
                    })
                    this.el.on("mouseleave", function () {
                        $(this).find("li").text(that.kongxin);
                        //end() 方法结束当前链条中的最近的筛选操作，并将匹配元素集还原为之前的状态。
                        $(this).find(".abc").text(that.shixin).prevAll().text(that.shixin).end().nextAll().text(that.kongxin)
                    })
                }
            }

            class secdshow {
                constructor(el) {
                    this.el = el;
                    this.show2 = this.el.parents(".section").find(".twoshow>.pol1");
                    this.olis = this.el.children()
                    this.dlis = this.show2.children();
                    this.mouseen();
                }
                mouseen() {
                    let that = this;
                    this.olis.mouseenter(function () {
                        let $index = $(this).index();
                        that.dlis.eq($index).show().siblings().hide()
                    }).mouseleave(function () {
                        that.dlis.hide()
                    })
                }
            }

            new toTop($(".toTop"));
            new goodstar($(".goodstar"));
            new secdshow($(".fix>ul"))

        }
    })
})()
$(window).load(function () {
    $(".toTop").omouse();
    $(".goodstar").omouse();
    $(".fix>ul").omouse();
    $("img.lazy").lazyload({ effect: "fadeIn", event: "scroll" });

})
